package com.chenjiahao.kaiyanwan.ui.discovery

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.chenjiahao.kaiyanwan.logic.dao.Repository
import com.hazz.kotlinmvp.mvp.model.bean.HomeBean

/**
 * Created by chenjh on 2020/9/18
 */
class CategoryDetailViewModel : ViewModel() {
    private val categoryDetailLiveData = MutableLiveData<Long>()
    var itemList = ArrayList<HomeBean.Issue.Item>()
    private var nextPageUrlLiveData = MutableLiveData<String>()
    //关注
    var categoryDetailNextPageUrl: String? = null

    val categoryDetailData = Transformations.switchMap(categoryDetailLiveData) {
        Repository.getCategoryDetailList(it)
    }

    val getIssueData = Transformations.switchMap(nextPageUrlLiveData) {
        Repository.getIssueData(it)
    }

    fun requestCategoryDetailData(id: Long) {
        categoryDetailLiveData.value = id
    }

    fun requestMoreData() {
        nextPageUrlLiveData.value = categoryDetailNextPageUrl
    }


}